package com.wwj.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;

import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;


import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Component  //注册bean到容器中
@Data
@AllArgsConstructor
@NoArgsConstructor
//将配置文件中配置的每一个属性的值，映射到这个组件中；参数 prefix = “person” : 将配置文件中的person下面的所有属性一一对应
@ConfigurationProperties(prefix = "person")
@Validated
//加载指定的配置文件
//@PropertySource(value = "classpath:emp.yaml")
public class Person {
//    //SPEL表达式取出配置文件的值
//    @Value("${name}")

    @Email(message = "邮箱格式有误")
    private String name;
    @Max(value = 20,message = "年龄最大不能超过20")
    private Integer age;
//    @NotNull(message="名字不能为空")
    private Boolean happy;
    private Date birth;
    private Map<String,Object> maps;
    private List<Object> lists;
    private Dog dog;

}
